/**
 *
 * Copyright (c) 2011 TLOSS. All rights reserved.
 * Created on Apr 22, 2011
 *
 */
package com.tloss.database.db2obj.utils;

import com.tloss.database.db2obj.Column;

/**
 * @author Tran Tung
 * 
 */
public class AnnotationUtils {
	public String getAnnotationDefine(Column column) {
		StringBuffer buffer = new StringBuffer();
		buffer.append("@javax.persistence.Column(");
		buffer.append("name=\"");
		buffer.append(column.getName());
		buffer.append("\"");
		buffer.append(",nullable=");
		buffer.append("yes".equalsIgnoreCase(column.getIsNullable()));
		if(column.getCharacterMaximumLength()>0){
			buffer.append(",length=");
			buffer.append(column.getCharacterMaximumLength());
		}
		if(column.getNumericPrecision()>0){
			buffer.append(",precision=");
			buffer.append(column.getNumericPrecision());
		}
		if(column.getNumericScale()>0){
			buffer.append(",scale=");
			buffer.append(column.getNumericScale());
		}
		buffer.append(")");
		return buffer.toString();
	}
}
